<template>
  <!-- 门锁-参数模板 -->
  <div class="consumer_machine">
    <el-row>
      <dragdrop :width="0" :widthLeft="'170px'">
        <template slot="left">
          <div class="left_shuju">
            <div class="grid-content bg-purple">
              <div class="header_title">
                <span>模板数据</span>
              </div>
              <div class="addtemplate" v-if="isauth('lock_p_edit')">
                <el-button
                  title="新增"
                  type="primary"
                  size="mini"
                  @click="addtForm"
                  icon="el-icon-plus"
                  >新增模板</el-button
                >
              </div>
              <el-table
                :data="tableData"
                :height="'calc(100vh - 220px)'"
                border
                @row-click="rowClick"
                highlight-current-row
                style="width: 100%"
                :header-cell-style="headFirst"
              >
                <el-table-column
                  align="center"
                  prop="templateName"
                  label="模板名称"
                ></el-table-column>
                <el-table-column
                  label="操作"
                  align="center"
                  v-if="isauth('lock_p_edit')"
                >
                  <template slot-scope="scope">
                    <el-button
                      type="text"
                      size="mini"
                      @click.stop="eidtDate(scope.row)"
                      >修改密码</el-button
                    >

                    <el-button
                      v-if="userType === '1' || userType == '50' ? true : false"
                      type="text"
                      size="mini"
                      @click.stop="resetDate(scope.row)"
                      >重置密码</el-button
                    >
                    <el-button
                      type="text"
                      size="mini"
                      style="color: red"
                      @click.stop="deleteDate(scope.row)"
                      >删除</el-button
                    >
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
        </template>
        <template slot="right">
          <div class="right_shuju">
            <div class="grid-content bg-purple-light" v-if="isShow">
              <el-tabs
                type="border-card"
                v-model="activeName"
                @tab-click="handleClick"
              >
                <!-- 基础设置 -->
                <el-tab-pane label="基础参数" name="third">
                  <el-form
                    :model="ruleForm"
                    :inline="true"
                    :rules="rules"
                    ref="ruleForm"
                    class="demo-ruleForm"
                  >
                    <!-- 1 -->
                    <el-row>
                      <el-col :span="9">
                        <el-form-item
                          label="开门时长(1~255)"
                          prop="openingTime"
                        >
                          <el-input-number
                            v-model="ruleForm.openingTime"
                            :min="1"
                            :max="255"
                            label
                            size="mini"
                            style="width: 100px"
                          ></el-input-number>
                          <span>秒</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item label="休息间隔" prop="sleepTime">
                          <el-input-number
                            v-model="ruleForm.sleepTime"
                            :min="0"
                            :max="65535"
                            label
                            size="mini"
                          ></el-input-number>
                          <span>秒</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="7">
                        <el-form-item label="电压限制" prop="cellReportVoltage">
                          <el-input-number
                            v-model="ruleForm.cellReportVoltage"
                            :min="0"
                            :max="25.5"
                            label
                            size="mini"
                            style="width: 100px"
                          ></el-input-number>
                          <span>V</span>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- 2 -->
                    <el-row>
                      <el-col :span="6">
                        <el-form-item
                          label="是否保存非法卡"
                          prop="illegalCardStorage"
                        >
                          <el-checkbox
                            v-model="ruleForm.illegalCardStorage"
                          ></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item
                          label="是否检测假锁"
                          prop="isCheckFalseLock"
                        >
                          <el-checkbox
                            v-model="ruleForm.isCheckFalseLock"
                          ></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="5">
                        <el-form-item label="是否为无线模式" prop="isWireless">
                          <el-checkbox
                            v-model="ruleForm.isWireless"
                          ></el-checkbox>
                        </el-form-item>
                      </el-col>
                      <el-col :span="7">
                        <el-form-item
                          label="刷卡成功是否提示声音"
                          prop="swipeCardIsSound"
                          width="300px"
                        >
                          <el-checkbox
                            v-model="ruleForm.swipeCardIsSound"
                          ></el-checkbox>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- 3 -->
                    <el-row>
                      <el-col :span="6">
                        <el-form-item
                          label="开门方式"
                          prop="cardEncryptionModel"
                        >
                          <el-select
                            v-model="ruleForm.cardEncryptionModel"
                            placeholder="请选择开门方式"
                            size="mini"
                            style="width: 100px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in cardEncryptionModelOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="名单长度" prop="rosterLength">
                          <el-select
                            v-model="ruleForm.rosterLength"
                            placeholder="请选择"
                            size="mini"
                            style="width: 100px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in rosterLengthOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="卡类型" prop="icModel">
                          <el-select
                            v-model="ruleForm.icModel"
                            placeholder="请选择"
                            size="mini"
                            style="width: 100px"
                          >
                            <el-option
                              :label="item.label"
                              :value="item.value"
                              v-for="item in icModelOption"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="6">
                        <el-form-item label="IC扇区" prop="icCardSector">
                          <el-select
                            v-model="ruleForm.icCardSector"
                            placeholder="请选择"
                            size="mini"
                            style="width: 100px"
                          >
                            <el-option
                              :label="item - 1"
                              :value="item - 1"
                              v-for="item in 16"
                              :key="item.value"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <!-- 4 -->
                    <el-row>
                      <el-col :span="10">
                        <el-form-item
                          label="调校卡模块周期"
                          prop="readCardResetSpace"
                        >
                          <el-input-number
                            v-model="ruleForm.readCardResetSpace"
                            :min="0"
                            :max="255"
                            label
                            size="mini"
                            style="width: 100px"
                          ></el-input-number>
                          <!-- <el-input
                        v-model="ruleForm.readCardResetSpace"
                        placeholder="请输入内容"
                        type="number"
                        size="mini"
                        style="width:80px"
                          ></el-input>-->
                          <span>分钟</span>
                        </el-form-item>
                      </el-col>
                      <el-col :span="12">
                        <el-form-item
                          label="IC卡密码(12位十六进制格式)"
                          prop="icCardPassword"
                        >
                          <el-input
                            v-model="ruleForm.icCardPassword"
                            placeholder="请输入内容"
                            size="mini"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-form>
                </el-tab-pane>
                <el-tab-pane label="星期时段配置" name="first">
                  <div class="consumption_rules">
                    <div class="explanation">
                      <!-- 星期时段配置 -->
                      <el-table
                        v-loading="loading"
                        :data="weekTimeList"
                        ref="table"
                        border
                        :header-cell-style="headFirst"
                        style="width: 100%"
                        height="calc(100vh - 270px)"
                        :cell-style="(res) => headFirst_col(res, [], 2)"
                      >
                        <el-table-column
                          align="center"
                          prop="timeNumber"
                          label="时段"
                          min-width="70px"
                        >
                          <template slot-scope="scope"
                            >时段{{ scope.row.timeNumber }}</template
                          >
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime1"
                          label="开始时间1"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime1"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime1"
                          label="结束时间1"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime1"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime2"
                          label="开始时间2"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime2"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime2"
                          label="结束时间2"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime2"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime3"
                          label="开始时间3"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime3"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime3"
                          label="结束时间3"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime3"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime4"
                          label="开始时间4"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime4"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime4"
                          label="结束时间4"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime4"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime5"
                          label="开始时间5"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime5"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime5"
                          label="结束时间5"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime5"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime6"
                          label="开始时间6"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime6"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime6"
                          label="结束时间6"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime6"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime7"
                          label="开始时间7"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime7"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime7"
                          label="结束时间7"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime7"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime8"
                          label="开始时间8"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime8"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime8"
                          label="结束时间8"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime8"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime9"
                          label="开始时间9"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime9"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime9"
                          label="结束时间9"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime9"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime10"
                          label="开始时间10"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime10"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime10"
                          label="结束时间10"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime10"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime11"
                          label="开始时间11"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime11"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime11"
                          label="结束时间11"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime11"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="stateTime12"
                          label="开始时间12"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.stateTime12"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                        <el-table-column
                          align="center"
                          prop="endTime12"
                          label="结束时间12"
                          min-width="110px"
                        >
                          <template slot-scope="scope">
                            <el-time-picker
                              v-model="scope.row.endTime12"
                              placeholder="选择时间"
                              @change="change"
                              value-format="HH:mm"
                              format="HH:mm"
                              style="width: 100px"
                              size="mini"
                            ></el-time-picker>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </div>
                </el-tab-pane>
                <el-tab-pane label="假日时段配置" name="second">
                  <!-- 假日时段配置 -->
                  <el-table
                    v-loading="loading"
                    :data="holidayList"
                    ref="holidayList"
                    border
                    :header-cell-style="headFirst"
                    height="calc(100vh - 270px)"
                     :cell-style="(res) => headFirst_col(res, [], 2)"
                  >
                    <el-table-column
                      align="center"
                      prop="timeNumber"
                      label="时段"
                      max-width="70px"
                    >
                      <template slot-scope="scope"
                        >时段{{ scope.row.timeNumber }}</template
                      >
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateTime1"
                      label="开始时间1"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.stateTime1"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endTime1"
                      label="结束时间1"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.endTime1"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateTime2"
                      label="开始时间2"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.stateTime2"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endTime2"
                      label="结束时间2"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.endTime2"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateTime3"
                      label="开始时间3"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.stateTime3"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endTime3"
                      label="结束时间3"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.endTime3"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateTime4"
                      label="开始时间4"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.stateTime4"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endTime4"
                      label="结束时间4"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.endTime4"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateTime5"
                      label="开始时间5"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.stateTime5"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endTime5"
                      label="结束时间5"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.endTime5"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateTime6"
                      label="开始时间6"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.stateTime6"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endTime6"
                      label="结束时间6"
                      min-width="110px"
                    >
                      <template slot-scope="scope">
                        <el-time-picker
                          v-model="scope.row.endTime6"
                          placeholder="选择时间"
                          @change="change"
                          value-format="HH:mm"
                          format="HH:mm"
                          style="width: 100px"
                          size="mini"
                        ></el-time-picker>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <!-- 假日配置 -->
                <el-tab-pane label="假日配置" name="holidaySetupList">
                  <el-table
                    v-loading="loading"
                    :data="holidaySetupList"
                    ref="holidaySetupList"
                    border
                    :header-cell-style="headFirst"
                    :cell-style="(res) => headFirst_col(res, [], 2)"
                  >
                    <el-table-column
                      align="center"
                      prop="holidayNumber"
                      label="时段"
                      max-width="100px"
                    >
                      <template slot-scope="scope"
                        >时段{{ scope.row.holidayNumber + 1 }}</template
                      >
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="validFlag"
                      label="是否启用"
                      width="60px"
                    >
                      <template slot-scope="scope">
                        <el-checkbox
                          v-model="scope.row.validFlag"
                        ></el-checkbox>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateDate"
                      label="开始时间"
                      min-width="60px"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.stateDate"
                          type="date"
                          placeholder="选择日期"
                          value-format="yyyy-MM-dd"
                          size="mini"
                          class="picker_width"
                        ></el-date-picker>
                        <!-- <el-date-picker
                      v-model="scope.row.stateDate"
                      type="datetime"
                      placeholder="选择日期时间"
                      value-format="yyyy-MM-dd HH:mm:ss"
                      size="mini"
                      style="width:180px"
                        ></el-date-picker>-->
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endDate"
                      label="结束时间"
                      min-width="60px"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.endDate"
                          type="date"
                          placeholder="选择日期"
                          value-format="yyyy-MM-dd"
                          size="mini"
                          class="picker_width"
                        ></el-date-picker>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <!-- 例外假日配置 -->
                <el-tab-pane label="例外假日配置" name="holidayOtherList">
                  <el-table
                    v-loading="loading"
                    :data="holidayOtherList"
                    ref="holidayOtherList"
                    border
                    :header-cell-style="headFirst"
                                        :cell-style="(res) => headFirst_col(res, [], 2)"

                  >
                    <el-table-column
                      align="center"
                      prop="holidayNumber"
                      label="时段"
                      max-width="100px"
                    >
                      <template slot-scope="scope"
                        >时段{{ scope.row.holidayNumber }}</template
                      >
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="validFlag"
                      label="是否启用"
                      width="60px"
                    >
                      <template slot-scope="scope">
                        <el-checkbox
                          v-model="scope.row.validFlag"
                        ></el-checkbox>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="stateDate"
                      label="开始时间"
                      min-width="60px"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.stateDate"
                          type="date"
                          placeholder="选择日期"
                          value-format="yyyy-MM-dd"
                          size="mini"
                          class="picker_width"
                        ></el-date-picker>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="endDate"
                      label="结束时间"
                      min-width="60px"
                    >
                      <template slot-scope="scope">
                        <el-date-picker
                          v-model="scope.row.endDate"
                          type="date"
                          placeholder="选择日期"
                          value-format="yyyy-MM-dd"
                          size="mini"
                          class="picker_width"
                        ></el-date-picker>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <el-tab-pane label="超级用户配置" name="superUserSetupList">
                  <el-table
                    v-loading="loading"
                    :data="superUserSetupList"
                    ref="superUserSetupList"
                    border
                    :header-cell-style="headFirst"
                                       :cell-style="(res) => headFirst_col(res, [], 2)"

                  >
                    <el-table-column
                      align="center"
                      prop="userNumber"
                      label
                      max-width="100px"
                    >
                      <template slot-scope="scope">{{
                        scope.$index | userNumberType
                      }}</template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="validFlagOne"
                      label="是否启用"
                      width="60px"
                    >
                      <template slot-scope="scope">
                        <el-checkbox
                          v-model="scope.row.validFlagOne"
                        ></el-checkbox>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="userPasswordOne"
                      label="密码(6位数)"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model.number="scope.row.userPasswordOne"
                          placeholder="请输入内容"
                          size="mini"
                          style="width: 160px"
                          maxlength="6"
                        ></el-input>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="validFlagTwo"
                      label="是否启用"
                      width="60px"
                    >
                      <template slot-scope="scope">
                        <el-checkbox
                          v-model="scope.row.validFlagTwo"
                        ></el-checkbox>
                      </template>
                    </el-table-column>
                    <el-table-column
                      align="center"
                      prop="userPasswordTwo"
                      label="密码(6位数)"
                    >
                      <template slot-scope="scope">
                        <el-input
                          v-model.number="scope.row.userPasswordTwo"
                          placeholder="请输入内容"
                          size="mini"
                          style="width: 160px"
                          maxlength="6"
                        ></el-input>
                      </template>
                    </el-table-column>
                  </el-table>
                </el-tab-pane>
                <!-- 周休息日配置 -->
                <el-tab-pane label="周休息日配置" name="restDay">
                  <el-form
                    :model="restDay"
                    :inline="true"
                    ref="ruleRestDay"
                    class="demo-ruleForm"
                  >
                    <el-row>
                      <el-col :span="6">
                        <el-form-item label prop="validFlagAll">
                          <el-checkbox v-model="restDay.validFlagAll"
                            >是否有效</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="3">
                        <el-form-item label prop="monValidFlag">
                          <el-checkbox v-model="restDay.monValidFlag"
                            >星期一</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label prop="tueValidFlag">
                          <el-checkbox v-model="restDay.tueValidFlag"
                            >星期二</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label prop="wedValidFlag" width="300px">
                          <el-checkbox v-model="restDay.wedValidFlag"
                            >星期三</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label prop="thuValidFlag">
                          <el-checkbox v-model="restDay.thuValidFlag"
                            >星期四</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label prop="friValidFlag">
                          <el-checkbox v-model="restDay.friValidFlag"
                            >星期五</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label prop=" satValidFlag" width="300px">
                          <el-checkbox v-model="restDay.satValidFlag"
                            >星期六</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                      <el-col :span="3">
                        <el-form-item label prop=" sunValidFlag" width="300px">
                          <el-checkbox v-model="restDay.sunValidFlag"
                            >星期天</el-checkbox
                          >
                        </el-form-item>
                      </el-col>
                    </el-row>
                  </el-form>
                </el-tab-pane>
              </el-tabs>
              <div class="footer" v-if="isauth('lock_p_edit')">
                <el-card class="box-card">
                  <div class="footerflex">
                    <div class="footer_save">
                      <el-input
                        size="mini"
                        v-model="alldatatemplatePassword"
                        show-password
                        placeholder="请输入密码后，再点保存"
                      ></el-input>
                    </div>
                    <div class="footer_save">
                      <el-button type="primary" size="mini" @click="savealldata"
                        >保存</el-button
                      >
                    </div>
                    <div class="footer_merchant_equipment_parameters">
                      <el-button
                        type="primary"
                        size="mini"
                        @click="savemerchant"
                        >重发参数模板</el-button
                      >
                    </div>
                  </div>
                </el-card>
              </div>
            </div>
          </div>
        </template>
      </dragdrop>
    </el-row>
    <!-- 新增 -->
    <el-dialog
      :before-close="closeDialog"
      width="500px"
      center
      title="新增模板"
      :close-on-click-modal="false"
      :visible.sync="addDialogFormVisible"
    >
      <el-form
        :model="adddataForm"
        :rules="adddataRule"
        ref="adddataForm"
        label-width="80px"
      >
        <el-form-item label="模板名称" prop="templateName">
          <el-col :span="15">
            <el-input
              v-model="adddataForm.templateName"
              placeholder="用户名称"
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="模板密码" prop="templatePassword">
          <el-col :span="15">
            <el-input
              v-model="adddataForm.templatePassword"
              placeholder="用户密码"
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addvisible()">取消</el-button>
        <el-button type="primary" @click="addFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog
      :before-close="eidtcloseDialog"
      width="500px"
      center
      title="修改模板"
      :close-on-click-modal="false"
      :visible.sync="eidtDialogFormVisible"
    >
      <el-form
        :model="eidtdataForm"
        :rules="adddataRule"
        ref="eidtdataForm1"
        label-width="90px"
      >
        <el-form-item label="模板名称" prop="templateName">
          <el-col :span="15">
            <el-input
              v-model="eidtdataForm.templateName"
              placeholder="模板名称"
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="新模板密码" prop="newPassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入新密码"
              v-model="eidtdataForm.newPassword"
              show-password
              :disabled="eidtdataForm.changepassword === false ? true : false"
              size="mini"
            ></el-input>
          </el-col>
          <el-col :span="5" style="paddingleft: 20px">
            <el-checkbox v-model="eidtdataForm.changepassword"
              >是否修改密码</el-checkbox
            >
          </el-col>
        </el-form-item>
        <el-form-item label="原模板密码" prop="oldPassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入密码,无则不填密"
              v-model="eidtdataForm.oldPassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="eidtvisible()">取消</el-button>
        <el-button type="primary" @click="eidtFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
    <!-- 重置 -->
    <el-dialog
      :before-close="resetcloseDialog"
      width="500px"
      center
      title="重置密码"
      :close-on-click-modal="false"
      :visible.sync="resetDialogFormVisible"
    >
      <el-form
        :model="resetdataForm"
        ref="resetdataForm"
        :rules="resetRule"
        label-width="110px"
      >
        <el-form-item label="模板密码" prop="templatePassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入密码"
              v-model="resetdataForm.templatePassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
        <el-form-item label="确认模板密码" prop="confirmtemplatePassword">
          <el-col :span="15">
            <el-input
              placeholder="请输入新密码"
              v-model="resetdataForm.confirmtemplatePassword"
              show-password
              size="mini"
            ></el-input>
          </el-col>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetvisible()">取消</el-button>
        <el-button type="primary" @click="resetFormSubmit()">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { JSEncrypt } from "jsencrypt";

export default {
  data() {
    let checkcreditCardSpaceTime = (rule, value, callback) => {
      // /^(0|[1-9]\d*)(\.\d*)?$/
      let CardSpaceTime = /^(([0-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5]))))$/;
      if (!CardSpaceTime.test(value)) {
        callback(new Error("请输入正确的时间格式！"));
      } else {
        callback();
      }
    };
    let resetPassword = (rule, value, callback) => {
      if (this.resetdataForm.templatePassword !== value) {
        callback(new Error("确认密码与新密码不一致"));
      } else {
        callback();
      }
    };
    return {
      isShow: false,
      // 加密
      publicKey:
        "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCx8wyZzYxaffWrJ4jooN554npe5vD2RSQGNXOY5UZz6hcIW0jdEk1KcdclE7mJPiI2DmgUjBp4Lau+bNmZxmLBqFHUMd29mWyqX+LuYVoymxs8f3VJF+7PqZzuKbtSOyXfcyjIIgtB06YlX4SXx4FCErGRx+MDseN2ObHSPme/3wIDAQAB",
      /** 控制隐藏显示效果 */
      leftS: 5,
      rightS: 19,
      isrightS: false,
      isletfS: true,
      /** 模板数据 */
      // 当前面板
      activeName: "third",
      // 模板列表
      tableData: [],
      // 模板id
      templateGuid: "",
      templateName: "",
      // 模板名称
      adddataForm: {
        templateName: "",
        templatePassword: "",
      },
      // 模板规则
      adddataRule: {
        templateName: [
          { required: true, message: "模板名称不能为空", trigger: "blur" },
        ],
      },
      // 修改模板弹窗
      eidtDialogFormVisible: false,
      // 修改数据
      eidtdataForm: {
        templateName: "",
        oldPassword: "",
        newPassword: "",
        changepassword: false,
      },
      // 重置密码弹窗
      resetDialogFormVisible: false,
      // 重置密码
      resetdataForm: {
        templatePassword: "",
        confirmtemplatePassword: "",
      },
      // 重置密码规则
      resetRule: {
        templatePassword: [
          { required: true, message: "模板密码不能为空", trigger: "blur" },
        ],
        confirmtemplatePassword: [
          { required: true, message: "确认模板密码不能为空", trigger: "blur" },
          { validator: resetPassword, trigger: "blur" },
        ],
      },
      // 新增模板弹窗
      addDialogFormVisible: false,
      // 加载框框
      loading: false,
      /** 基础参数配置 */
      // 开门方式,选项
      cardEncryptionModelOption: [
        { label: "仅卡", value: 0 },
        { label: "卡或密码", value: 1 },
        { label: "卡和密码", value: 2 },
      ],
      // 名单长度
      rosterLengthOption: [
        { label: "16字节", value: 0 },
        { label: "32字节", value: 55 },
      ],
      // 卡类型
      icModelOption: [
        { label: "ID卡", value: 0 },
        { label: "IC卡", value: 55 },
      ],
      /**基础设置 */
      ruleForm: {
        // 开门时长
        openingTime: 0,
        // 休眠间隔
        sleepTime: 0,
        // 是否保存非法卡
        illegalCardStorage: true,
        // 是否检测假锁
        isCheckFalseLock: true,
        // 是否为无线模式
        isWireless: false,
        // 刷卡成功是否提示声音
        swipeCardIsSound: false,
        // 开门方式
        cardEncryptionModel: 0,
        // 名单长度
        rosterLength: 0,
        // 卡类型
        icModel: 0,
        // IC扇区
        icCardSector: 0,
        // 电压限制
        cellReportVoltage: 0,
        // 调校卡模块周期
        readCardResetSpace: 2,
        // IC卡密码(12位十六进制格式)
        icCardPassword: 123456789123,
      },
      rules: {
        icCardPassword: [
          {
            min: 12,
            max: 12,
            message: "必须是12位十六进制格式卡号",
            trigger: "blur",
          },
        ],
      },

      /** 星期时段配置数据 */
      weekTimeList: [],
      /** 假日时段配置数据 */
      holidayList: [],
      /**假日配置数据 */
      holidaySetupList: [],
      /** 例外假日配置 */
      holidayOtherList: [],
      /** 周休息日配置 */
      restDay: {},
      ruleRestDay: {},
      /** 超级用户设置数据 */
      superUserSetupList: [],

      // 参数模板密码验证
      alldatatemplatePassword: "",
    };
  },
  filters: {
    userNumberType(val) {
      if (val >= 4) {
        return `胁迫密码${val - 3}`;
      } else {
        return `超级密码${val + 1}`;
      }
    },
  },
  created() {
    this.operatorGuid = sessionStorage.getItem("administrator");
    this.userType = sessionStorage.getItem("userType");
  },
  mounted() {
    this.getmodelselect();
    // this.activeName = "first";
  },
  computed: {
    documentClientHeight: {
      get() {
        return this.$store.state.common.documentClientHeight;
      },
    },
    changeschoolid: {
      get() {
        return this.$store.state.user.changeschoolid;
      },
    },
  },
  methods: {
    leftSClick() {
      this.isrightS = true;
      this.leftS = 0;
      this.rightS = 24;
      this.isletfS = false;
    },
    rightSClick() {
      this.isrightS = false;
      this.leftS = 5;
      this.rightS = 19;
      this.isletfS = true;
    },
    change(val) {
      console.log(val);
    },
    /**
     * 模板添加
     */
    addtForm() {
      this.addDialogFormVisible = true;
    },
    addvisible() {
      this.addDialogFormVisible = false;
      this.$refs["adddataForm"].resetFields();
    },
    closeDialog(done) {
      this.$refs["adddataForm"].resetFields();
      done();
    },
    // 新增模板
    addFormSubmit() {
      this.$refs["adddataForm"].validate((valid) => {
        if (valid) {
          console.log(this.adddataForm.templatePassword);
          if (
            this.adddataForm.templatePassword === "" ||
            this.adddataForm.templatePassword === null
          ) {
            var templatePassword = "";
          } else {
            let encryptor = new JSEncrypt();
            encryptor.setPublicKey(this.publicKey);
            var templatePassword = encryptor.encrypt(
              this.$md5(this.adddataForm.templatePassword)
            );
          }
          console.log(templatePassword);
          this.$http({
            url: this.$http.adornUrl(
              "/terminal/doorLock/lock-date-parameter-add"
            ),
            method: "post",
            data: this.$http.adornData({
              messageContent: {
                templateName: this.adddataForm.templateName,
                unitGuid: this.changeschoolid,
                templatePassword: templatePassword,
              },
              messageType: this.messageType,
            }),
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: "新增成功",
                type: "success",
              });
              this.$refs["adddataForm"].resetFields();
              this.getmodelselect();
              this.addDialogFormVisible = false;
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: "error",
              });
            }
          });
        }
      });
    },
    // 修改模板
    eidtDate(row) {
      this.eidtDialogFormVisible = true;
      this.eidtdataForm.changepassword = false;
      this.eidtdataForm.templateGuid = row.templateGuid;
      this.$set(this.eidtdataForm, "templateName", row.templateName);
      console.log(row);
    },
    eidtcloseDialog(done) {
      this.$refs["eidtdataForm1"].resetFields();

      done();
    },
    // 取消修改
    eidtvisible() {
      this.$refs["eidtdataForm1"].resetFields();
      this.eidtDialogFormVisible = false;
    },
    // 确定修改
    eidtFormSubmit() {
      this.$refs["eidtdataForm1"].validate((valid) => {
        if (valid) {
          if (
            this.eidtdataForm.oldPassword === "" ||
            this.eidtdataForm.oldPassword === null
          ) {
            var oldPassword = "";
          }
          if (
            this.eidtdataForm.newPassword === "" ||
            this.eidtdataForm.newPassword === null
          ) {
            var newPassword = "";
          }
          if (
            this.eidtdataForm.oldPassword !== "" &&
            this.eidtdataForm.oldPassword !== null
          ) {
            let encryptor = new JSEncrypt();
            encryptor.setPublicKey(this.publicKey);
            var oldPassword = encryptor.encrypt(
              this.$md5(this.eidtdataForm.oldPassword)
            );
          }
          if (
            this.eidtdataForm.newPassword !== "" &&
            this.eidtdataForm.newPassword !== null
          ) {
            let encryptor = new JSEncrypt();
            encryptor.setPublicKey(this.publicKey);
            var newPassword = encryptor.encrypt(
              this.$md5(this.eidtdataForm.newPassword)
            );
          }
          if (this.eidtdataForm.changepassword == false) {
            var newPassword = null;
          }
          this.$http({
            url: this.$http.adornUrl("/terminal/template-update-password"),
            method: "post",
            data: this.$http.adornData({
              messageContent: {
                newPassword: newPassword,
                oldPassword: oldPassword,
                unitGuid: this.changeschoolid,
                templateName: this.eidtdataForm.templateName,
                templateGuid: this.eidtdataForm.templateGuid,
                terminalType: 22,
              },
              messageType: this.messageType,
            }),
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: "修改成功",
                type: "success",
              });
              this.getmodelselect();
              this.$refs["eidtdataForm1"].resetFields();
              this.eidtDialogFormVisible = false;
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: "error",
              });
            }
          });
        }
      });
    },
    // 获取门锁模板参数列
    getmodelselect() {
      this.$http({
        url: this.$http.adornUrl("/terminal/template-model-select"),
        method: "post",
        data: this.$http.adornData({
          messageContent: {
            terminalType: 22,
            unitGuid: this.changeschoolid,
          },
          messageType: this.messageType,
        }),
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          console.log(data);
          this.tableData = data.messageContent;
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: "error",
          });
        }
      });
    },

    /**
     * 模板重置
     */
    resetDate(row) {
      console.log(row);
      this.resetdataForm.templateGuid = row.templateGuid;
      this.resetDialogFormVisible = true;
    },
    resetvisible() {
      this.resetDialogFormVisible = false;
      this.$refs["resetdataForm"].resetFields();
    },
    resetcloseDialog(done) {
      this.$refs["resetdataForm"].resetFields();
      done();
    },
    resetFormSubmit() {
      this.$refs["resetdataForm"].validate((valid) => {
        if (valid) {
          let encryptor = new JSEncrypt();
          encryptor.setPublicKey(this.publicKey);
          let confirmtemplatePassword = encryptor.encrypt(
            this.$md5(this.resetdataForm.confirmtemplatePassword)
          );
          this.$http({
            url: this.$http.adornUrl("/terminal/template-reset-password"),
            method: "post",
            data: this.$http.adornData({
              messageContent: {
                templatePassword: confirmtemplatePassword,
                templateGuid: this.resetdataForm.templateGuid,
                unitGuid: this.changeschoolid,
                operatorGuid: this.operatorGuid,
              },
              messageType: this.messageType,
            }),
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                showClose: true,
                message: "重置成功",
                type: "success",
              });
              this.getmodelselect();
              this.$refs["resetdataForm"].resetFields();
              this.resetDialogFormVisible = false;
            } else {
              this.$message({
                showClose: true,
                message: data.errorMessage,
                type: "error",
              });
            }
          });
        }
      });
    },
    // 点击当前模板触发
    rowClick(row) {
      console.log(row);
      this.isShow = true;
      this.templateGuid = row.templateGuid;
      this.templateName = row.templateName;
      this.getLockList();
    },
    // 删除模板
    deleteDate(row) {
      this.$prompt("请输入密码,无则不输入", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(({ value }) => {
          if (value !== null && value !== "") {
            let templatePassword = value;
            let encryptor = new JSEncrypt();
            encryptor.setPublicKey(this.publicKey);
            templatePassword = encryptor.encrypt(this.$md5(templatePassword));
            this.deletconsumptiondata(row, templatePassword);
          } else {
            let templatePassword = "";
            this.deletconsumptiondata(row, templatePassword);
          }
        })
        .catch(() => {});
    },
    //删除模板数据
    deletconsumptiondata(row, templatePassword) {
      this.$http({
        url: this.$http.adornUrl("/terminal/consume/consume-parameter-delete"),
        method: "post",
        data: this.$http.adornData({
          messageContent: {
            templateGuid: row.templateGuid,
            unitGuid: this.changeschoolid,
            templatePassword: templatePassword,
          },
          messageType: 0,
        }),
      }).then(({ data }) => {
        console.log(data);
        if (data.messageCode == 200) {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
          this.getmodelselect();
        } else {
          this.$message.error(data.errorMessage);
        }
      });
    },
    // 门锁参数模板查询
    getLockList() {
      this.$http({
        url: this.$http.adornUrl(
          "/terminal/doorLock/lock-date-parameter-search"
        ),
        method: "post",
        data: this.$http.adornData({
          messageContent: {
            templateGuid: this.templateGuid,
            unitGuid: this.changeschoolid,
          },
          messageType: this.messageType,
        }),
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          console.log(data.messageContent);
          // 星期时段配置
          this.weekTimeList = data.messageContent.weekTimeList;
          // 假日时段配置
          this.holidayList = data.messageContent.holidayList;
          // 假日配置
          this.holidaySetupList = data.messageContent.holidaySetupList;
          // 例外假日配置
          this.holidayOtherList = data.messageContent.holidayOtherList;
          // 周休息日配置
          this.restDay = data.messageContent.restDay;
          // 超级用户配置
          this.superUserSetupList = data.messageContent.superUserSetupList;
          /** 基础参数 */
          // 开门时长
          this.ruleForm.openingTime = data.messageContent.openingTime;
          // 休眠间隔
          this.ruleForm.sleepTime = data.messageContent.sleepTime;
          // 是否保存非法卡
          this.ruleForm.illegalCardStorage =
            data.messageContent.illegalCardStorage == 1 ? true : false;
          // 是否检测假锁
          this.ruleForm.isCheckFalseLock = data.messageContent.isCheckFalseLock;
          // 是否为无线模式
          this.ruleForm.isWireless = data.messageContent.isWireless;
          // 刷卡成功是否提示声音
          this.ruleForm.swipeCardIsSound = data.messageContent.swipeCardIsSound;
          // 开门方式
          this.ruleForm.cardEncryptionModel =
            data.messageContent.cardEncryptionModel;
          // 名单长度
          this.ruleForm.rosterLength = data.messageContent.rosterLength;
          // 卡类型
          this.ruleForm.icModel = data.messageContent.icModel;
          // IC扇区
          this.ruleForm.icCardSector = data.messageContent.icCardSector;
          // 电压限制
          this.ruleForm.cellReportVoltage =
            data.messageContent.cellReportVoltage / 10;
          // 调校卡模块周期
          this.ruleForm.readCardResetSpace =
            data.messageContent.readCardResetSpace;
          // IC卡密码(12位十六进制格式)
          this.ruleForm.icCardPassword = data.messageContent.icCardPassword;
          // this.$message({
          //   showClose: true,
          //   message: "查询成功",
          //   type: "success",
          // });
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: "error",
          });
        }
      });
    },
    tishi(arr, str) {
      if (arr.length > 0) {
        let isKey = true;
        let keyArr = Object.keys(arr[0]);
        console.log(arr);
        arr.map((item) => {
          keyArr.map((key) => {
            if (item[key] == null) {
              this.$message({
                showClose: true,
                message: `请选择${str}时间`,
                type: "warning",
              });
              isKey = false;
              return isKey;
            }
          });
        });
        return isKey;
      }
    },
    // 保存按钮,修改数据
    savealldata() {
      if (this.templateGuid == "") {
        this.$message({
          showClose: true,
          message: "请选择模块",
          type: "warning",
        });
        return false;
      }
      if (this.ruleForm.icCardPassword.length > 12) {
        this.$message({
          message: "IC卡密码的长度必须小于12位",
          type: "warning",
        });
        return;
      }
      if (this.ruleForm.icCardPassword != "") {
        console.log()
        let arr = String(this.ruleForm.icCardPassword).split("");
        let is = false;
        let test = /^[0-9a-fA-F]$/;
        arr.some((item) => {
          if (!test.test(item)) {
            is = true;
          }
        });
         if (arr.length  != 12) {
          this.$message({
            message: "必须是12位十六进制格式卡号",
            type: "warning",
          });
          return;
        }
        if (is) {
          this.$message({
            message: "IC卡密码的每个字符都必须在0-9或a-f范围内",
            type: "warning",
          });
          return;
        }
      }

      // 限制
      if (!this.tishi(this.weekTimeList, "星期时段配置")) {
        return false;
      }
      if (!this.tishi(this.holidayList, "假日时段配置")) {
        return false;
      }
      if (!this.tishi(this.holidaySetupList, "假日配置")) {
        return false;
      }

      // if(!this.tishi(this.holidaySetupList)){
      //   return false;
      // }
      let parameterData = {};
      parameterData = { ...this.ruleForm };
      // 是否保存非法卡，1：存储 0：不存储
      parameterData.illegalCardStorage = parameterData.illegalCardStorage
        ? 1
        : 0;
      // 电压转换
      parameterData.cellReportVoltage = parameterData.cellReportVoltage * 10;
      // 星期时段配置
      parameterData.weekTimeList = this.weekTimeList;
      // 假日时段配置
      parameterData.holidayList = this.holidayList;
      // 假日配置
      parameterData.holidaySetupList = this.holidaySetupList;
      // 例外假日配置
      parameterData.holidayOtherList = this.holidayOtherList;
      // 周休息日配置
      parameterData.restDay = this.restDay;
      // 超级用户配置
      parameterData.superUserSetupList = this.superUserSetupList;

      // 模板密码处理
      if (
        this.alldatatemplatePassword !== "" &&
        this.alldatatemplatePassword !== null
      ) {
        var templatePassword1 = this.alldatatemplatePassword;
        let encryptor = new JSEncrypt();
        encryptor.setPublicKey(this.publicKey);
        templatePassword1 = encryptor.encrypt(this.$md5(templatePassword1));
      }

      this.editParametter(parameterData, templatePassword1);
    },
    editParametter(parameterData, templatePassword1) {
      this.$http({
        url: this.$http.adornUrl(
          "/terminal/doorLock/lock-date-parameter-update"
        ),
        method: "post",
        data: this.$http.adornData({
          messageContent: {
            parameterData: parameterData,
            // 当前操作的模板id
            templateGuid: this.templateGuid,
            // 当前操作模板
            templateName: this.templateName,
            // 学校id
            unitGuid: this.changeschoolid,
            templatePassword: templatePassword1,
          },
          messageType: this.messageType,
        }),
      }).then(({ data }) => {
        if (data.messageCode == 200) {
          this.$message({
            showClose: true,
            message: "保存成功",
            type: "success",
          });
          console.log(data);
        } else {
          this.$message({
            showClose: true,
            message: data.errorMessage,
            type: "error",
          });
        }
      });

      console.log("保存");
    },
    // 下发参数
    savemerchant() {
      if (this.templateGuid == null || this.templateGuid == "") {
        this.$message({
          type: "warning",
          message: "请选择参数模板!",
        });
        return;
      }
      this.$confirm("是否重发该模板的参数?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$http({
            url: this.$http.adornUrl("/terminal/reset-template"),
            method: "post",
            data: this.$http.adornData({
              messageContent: {
                templateGuid: this.templateGuid,
                unitGuid: this.changeschoolid,
              },
              messageType: 0,
            }),
          }).then(({ data }) => {
            if (data.messageCode == 200) {
              this.$message({
                type: "success",
                message: "下发成功!",
              });
            } else {
              this.$message.error(data.errorMessage);
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //卡片切换
    handleClick() {},
  },
};
</script>

<style lang="scss" scoped>
.consumer_machine {
    /deep/.el-table {
    /deep/tbody tr:hover > td {
      cursor: pointer;
    }
  }
  /deep/.el-form-item{
    margin-bottom: 0;
  }
  //滚动条的宽度
  ::-webkit-scrollbar {
    width: 15px;
    height: 15px;
  }
  //滚动条的滑块
  ::-webkit-scrollbar-thumb {
    background-color: #a1a3a9;
    border-radius: 3px;
  }
  .el-row {
    &:last-child {
      margin-bottom: 0;
    }
    .grid-content {
      .picker_width {
        width: 150px;
      }
      .header_title,
      .addtemplate {
        padding: 20px 0;
        font-weight: bolder;
        padding-left: 20px;
        border-bottom: 1px solid #e5e9f2;
        color: #909399;
        text-align: center;
        overflow: hidden;
      }
      .addtemplate {
        padding: 5px 0;
      }
    }
    .bg-purple {
      // background: #d3dce6;
      height: auto;
    }
    .bg-purple-light {
      padding-top:40px;
      .explanation .el-table th,
      .hostForm .el-table tr {
        font-weight: normal;
      }
      .margintoppx {
        margin-top: 20px;
      }
      .demo-form-inline,
      .demo-form-inline1 {
        padding-bottom: 20px;
        display: flex;
        /deep/.el-form-item__label {
          padding-right: 5px;
        }
        .el-radio + .el-radio {
          margin-right: 0px;
        }
        .el-form-item {
          margin-bottom: 0px;
        }
        .el-date-editor.el-input,
        .el-date-editor.el-input__inner {
          width: 100%;
        }
        .el-row {
          width: 100%;
        }
        .shi_jian_zhi,
        .xuan_zhe,
        .danxuan {
          display: flex;
          justify-content: center;
        }
      }
      .demo-form-inline1 {
        border-bottom: 1px solid #e5e9f2;
        .searchmarigin {
          margin-left: 20px;
        }
      }
      .consumption_rules {
        // padding: 20px;
        background-color: #f5f5f5;
      }
      .footer {
        height: 60px;
        display: flex;
        align-items: center;
        .el-card.is-always-shadow,
        .el-card.is-hover-shadow:focus,
        .el-card.is-hover-shadow:hover {
          width: 100%;
          height: 80%;
        }
      }
    }
  }
}
</style>